﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;

namespace YArchitech.Public
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class HYDrawingManage : HYExternalCommand
	{
		public override void FilterProcess()
		{
			base.FilterViewType.Remove((ViewType)1);
			base.FilterViewType.Remove((ViewType)2);
			base.FilterProcess();
		}

		public override Result HYExecute(ref string TranName)
		{
			TranName = "图纸管理";
			List<Element> elementByCategory = YJKElementFilter.GetElementByCategory(base.Doc, BuiltInCategory.OST_Views);
			List<Element> list = new List<Element>();
			foreach (Element element in elementByCategory)
			{
				View view = (View)element;
                if (view != null && !view.IsTemplate && ((int)view.ViewType == 1 || (int)view.ViewType == 2 || (int)view.ViewType == 10 || (int)view.ViewType == 117 || (int)view.ViewType == 4 || (int)view.ViewType == 3))
				{
					Parameter parameter = view.GetParameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER);
					if (parameter == null || !(parameter.AsString() != "") || parameter.AsString() == null)
					{
						list.Add(view);
					}
				}
			}
			List<Element> elementByCategory2 = YJKElementFilter.GetElementByCategory(base.Doc, BuiltInCategory.OST_Sheets);
			List<Element> elementByCategory3 = YJKElementFilter.GetElementByCategory(base.Doc, typeof(FamilySymbol), BuiltInCategory.OST_TitleBlocks);
			ViewDrawingForm viewDrawingForm = new ViewDrawingForm(list, elementByCategory2, elementByCategory3, base.Doc, "1");
			viewDrawingForm.ShowDialog();
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
